package com.tadpole.music.holder.me;

import android.annotation.SuppressLint;
import android.view.View;
import android.widget.TextView;

import com.tadpole.music.R;
import com.tadpole.music.adapter.base.BaseAdapter;
import com.tadpole.music.bean.me.MoNiErrorBottomBean;
import com.tadpole.music.holder.base.BaseViewHolder;
import com.tadpole.music.utils.NoDoubleClickListener;

import java.util.List;

/**
 * Created By 孙岩
 * on 2020/12/26
 */
public class MoNiErrorV2ViewHolder extends BaseViewHolder {
    private View itemView;
    private BaseAdapter.OnItemClickListener onItemClickListener;
    private List<MoNiErrorBottomBean.DataBeanX.DataBean> list;
    //作答时间
    private TextView tvTime;
    //正确率
    private TextView tvZhengQueLv;
    //时长
    private TextView tvShiChang;
    //错题数量
    private TextView tvCuoTi;

    public MoNiErrorV2ViewHolder(View itemView, BaseAdapter.OnItemClickListener onItemClickListener,List<MoNiErrorBottomBean.DataBeanX.DataBean> list) {
        super(itemView);
        this.itemView = itemView;
        this.onItemClickListener = onItemClickListener;
        this.list = list;
    }

    @SuppressLint("SetTextI18n")
    @Override
    public void init(final int position) {
        tvTime = itemView.findViewById(R.id.tvTime);
        tvZhengQueLv = itemView.findViewById(R.id.tvZhengQueLv);
        tvShiChang = itemView.findViewById(R.id.tvShiChang);
        tvCuoTi = itemView.findViewById(R.id.tvCuoTi);

        tvTime.setText(list.get(position).getCreated_at());
        tvZhengQueLv.setText(100-(list.get(position).getErr_num()*10)+"%");
        tvShiChang.setText(list.get(position).getTime()+"分钟");
        tvCuoTi.setText(list.get(position).getErr_num()+"道");

        itemView.setOnClickListener(new NoDoubleClickListener() {
            @Override
            protected void onNoDoubleClick(View v) {
                onItemClickListener.onItemClick(itemView,position);
            }
        });
    }
}
